package com.ksframework.common.entity;

import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;

import org.hibernate.annotations.GenericGenerator;

@SuppressWarnings("serial")
@MappedSuperclass
public class BaseEntity extends Persistent{
	
	public enum RecycleStatus{
		recycle,
		normal
	}

	protected String id;
	protected Integer version;
	//删除标识0代表正常，1删除
	protected RecycleStatus recycle;
	
	protected long modifyTime;

	@Id
	@GeneratedValue(generator = "pk")
	@Column(name = "id")
	@GenericGenerator(name = "pk", strategy = "com.ksframework.common.entity.IdGenerator")
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	@Version  //版本号,必须紧跟在id元素后面.(由hibernate自身维护，不需要程序员手动修改)
	public Integer getVersion() {
		return version;
	}


	public void setVersion(Integer version) {
		this.version = version;
	}


	@Enumerated(EnumType.ORDINAL)
	public RecycleStatus getRecycle() {
		return recycle;
	}


	public void setRecycle(RecycleStatus recycle) {
		this.recycle = recycle;
	}


	public long getModifyTime() {
		return modifyTime;
	}


	public void setModifyTime(long modifyTime) {
		this.modifyTime = modifyTime;
	}

	/*
	public boolean isNew() {
		return this.id == null || "".equals(this.id);
	}*/
}
